﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SFJDManagement
{
    /// <summary>
    /// Win_Edit.xaml 的交互逻辑
    /// </summary>
    public partial class Win_Edit : Window
    {
        Window win_Parent;

        public Win_Edit(Window window)
        {
            win_Parent = window;
            InitializeComponent();
            Title = "编辑";
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            ChoiceFunction();
        }

        private void IniToolbar()
        {

        }

        private void ChoiceFunction()
        {
            LayoutRoot.Children.Clear();
            //Width = 500;
            //Height = 200;
            Width = Double.NaN;
            Height = Double.NaN;
            Button but_Brigade = GetChoiceButtton("委托人");
            but_Brigade.Click += But_Brigade_Click;
            Button but_Contact = GetChoiceButtton("联系人");
            but_Contact.Click += But_Contact_Click;
            Button but_User = GetChoiceButtton("用户");
            but_User.Click += But_User_Click;
            Button but_Data = GetChoiceButtton("数据");
            but_Data.Click += But_Data_Click;
            StackPanel stackPanel = new StackPanel();
            stackPanel.Orientation = Orientation.Horizontal;
            stackPanel.HorizontalAlignment = HorizontalAlignment.Center;
            stackPanel.Children.Add(but_Brigade);
            stackPanel.Children.Add(but_Contact);
            stackPanel.Children.Add(but_User);
            stackPanel.Children.Add(but_Data);
            LayoutRoot.Children.Add(stackPanel);
        }

        private void But_Data_Click(object sender, RoutedEventArgs e)
        {
            LayoutRoot.Children.Clear();
            WindowState = WindowState.Maximized;
            Content = new Page_Edit_Data();
        }

        private void But_User_Click(object sender, RoutedEventArgs e)
        {
            LayoutRoot.Children.Clear();
            Content = new Page_Edit_Users();
        }

        private void But_Contact_Click(object sender, RoutedEventArgs e)
        {
            LayoutRoot.Children.Clear();
            Content = new Page_Edit_Contact();
        }

        private void But_Brigade_Click(object sender, RoutedEventArgs e)
        {
            LayoutRoot.Children.Clear();
            //NavigationService.GetNavigationService(this).Navigate("Page_Edit_Brigade.xaml", UriKind.Relative);
            Content = new Page_Edit_Brigade();
            //LayoutRoot.DataContext = new Page_Edit_Brigade();
        }

        private Button GetChoiceButtton (string str)
        {
            Button button = new Button();
            //button.Width = 100;
            button.Height = 100;
            button.FontSize = 20;
            button.Content = str;
            button.Margin = new Thickness(10, 10, 10, 10);
            button.Padding = new Thickness(10, 10, 10, 10);
            return button;
        }

        private void Window_Closed(object sender, EventArgs e)
        {
            win_Parent.Visibility = Visibility.Visible;
        }
    }
}
